﻿using System;
using mvcForum.Core.Interfaces.Services;
using System.Web.Security;

namespace mvcForum.Web.Services {

	public class AuthenticationService : IAuthenticationService {

		/// <summary>
		/// Method for signing in the given user.
		/// </summary>
		/// <param name="account">The acocunt to sign in</param>
		/// <param name="createPersistentCookie">A boolean indicating whether or not the the account is remember for next visit</param>
		public void SignIn(IAccount account, Boolean createPersistentCookie) {
			if (account == null) {
				throw new ArgumentNullException("account");
			}

			FormsAuthentication.SetAuthCookie(account.AccountName, createPersistentCookie);
		}

		/// <summary>
		/// Sign out the current authenticated user.
		/// </summary>
		public void SignOut() {
			FormsAuthentication.SignOut();
		}
	}
}